﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SlSyncLibrary;

namespace SlSyncApp
{
    public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();
        }

        private void btnClick(object sender, RoutedEventArgs e)
        {
            Executor.BeginBlock();
            Executor.Invoke(new Action<string, string>(BtnClickStatements),txtInput1.Text, txtInput2.Text);
            Executor.EndBlock();
        }

        private void BtnClickStatements(string in1, string in2)
        {
            string result;
            ApplicationServiceClientSync client = new ApplicationServiceClientSync();
            if (client.LookupDbSync(in1) == "OK")
            {
                result=client.GetDataSync(in2);
            } else
            {
                result = "KO";
            }
            MainDispatcher.Current.BeginInvoke(() => txtResult.Text = result);
        }
    }
}
